




/*
'===============================================================================
'  LinqHelper.DAO.ToursBase
'===============================================================================
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using LinqHelper;
using LinqHelper.Entity;
using LinqHelper.DAO;

namespace LinqHelper.DAO
{
	public class LqToursBase
	{
		public LqProvider provider = new LqProvider();
		
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public LqToursBase()
		{
			// Nothing for now.
		}
		
		public void Insert(LqToursEntity obj)
		{
			provider.GetTable<LqToursEntity>().InsertOnSubmit(obj);
            provider.SubmitChanges();
		}

		public void Update(LqToursEntity _obj)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.Id == _obj.Id
                    select obj;
			LqToursEntity tmp = q.First<LqToursEntity>();
			
			tmp.CatId = _obj.CatId;
			tmp.TourId = _obj.TourId;
			tmp.TourName = _obj.TourName;
			tmp.Cost = _obj.Cost;
			tmp.Photos = _obj.Photos;
			tmp.TourInfo = _obj.TourInfo;
			tmp.TourDetail = _obj.TourDetail;
			tmp.CreatedDate = _obj.CreatedDate;
			tmp.CreatedBy = _obj.CreatedBy;
			provider.SubmitChanges();
		}
		
		public void Delete(LqToursEntity obj)
		{
			provider.GetTable<LqToursEntity>().DeleteOnSubmit(obj);
            provider.SubmitChanges();
		}
		
		
		public void DeleteById(Guid Id)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.Id == Id
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByCatId(Guid CatId)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.CatId == CatId
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByTourId(string TourId)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.TourId == TourId
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByTourName(string TourName)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.TourName == TourName
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByCost(decimal Cost)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.Cost == Cost
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByPhotos(string Photos)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.Photos == Photos
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByTourInfo(string TourInfo)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.TourInfo == TourInfo
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByTourDetail(string TourDetail)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.TourDetail == TourDetail
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByCreatedDate(DateTime CreatedDate)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.CreatedDate == CreatedDate
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByCreatedBy(string CreatedBy)
		{
			var q = from obj in provider.GetTable<LqToursEntity>()
                    where obj.CreatedBy == CreatedBy
                    select obj;
					
            LqToursEntity ob = (LqToursEntity)q.First<LqToursEntity>();
            provider.GetTable<LqToursEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public LqToursEntity SelectOne(Guid Id)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.Id == Id
                        select obj;
            return query.First<LqToursEntity>();
		}

		public List<LqToursEntity> SelectAll()
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectById(Guid Id)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.Id == Id
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByCatId(Guid CatId)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.CatId == CatId
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByTourId(string TourId)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.TourId == TourId
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByTourName(string TourName)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.TourName == TourName
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByCost(decimal Cost)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.Cost == Cost
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByPhotos(string Photos)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.Photos == Photos
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByTourInfo(string TourInfo)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.TourInfo == TourInfo
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByTourDetail(string TourDetail)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.TourDetail == TourDetail
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByCreatedDate(DateTime CreatedDate)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.CreatedDate == CreatedDate
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		public List<LqToursEntity> SelectByCreatedBy(string CreatedBy)
		{
			var query = from obj in provider.GetTable<LqToursEntity>()
                        where obj.CreatedBy == CreatedBy
                        select obj;
            return query.ToList<LqToursEntity>();
		}
		
		
		

	}
}
